package com.seari.custody.controller;

import com.google.api.client.util.ArrayMap;
import com.seari.custody.bean.TechnicalType;
import com.seari.custody.constant.MessageConstant;
import com.seari.custody.pojo.MessageBean;
import com.seari.custody.service.StatisticsProjectService;
import com.seari.custody.service.TechnicalAdviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/Statistics")
public class StatisticsProjectController {

    @Autowired
    private StatisticsProjectService statisticsProjectService;


    /**
     * 项目申请数(区域划分)
     */
    @RequestMapping("/regionalism")
    public MessageBean TechnicalAudittype(@RequestBody Map<String, String> map) {
        MessageBean messageBean = new MessageBean();
        try {
            List<Map<String, Object>> stringObjectMap = statisticsProjectService.saverDivision(map);
            messageBean.setType(MessageConstant.SUCCESS_TYPE);
            messageBean.setCode(MessageConstant.SUCCESS);
            messageBean.setMessage("查询技审类型成功");
            messageBean.setData(stringObjectMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType(MessageConstant.FAIL_TYPE);
            messageBean.setCode(MessageConstant.FAIL);
            messageBean.setMessage("查询技审类型失败");
        }
        return messageBean;
    }


    /**
     * 项目线路申请数量统计
     */
    @RequestMapping("/line")
    public MessageBean line(@RequestBody Map<String, String> map) {
        MessageBean messageBean = new MessageBean();
        try {
           Map<String, Object> stringObjectMap = statisticsProjectService.saverline(map);
            messageBean.setType(MessageConstant.SUCCESS_TYPE);
            messageBean.setCode(MessageConstant.SUCCESS);
            messageBean.setMessage("查询线路统计情况成功");
            messageBean.setData(stringObjectMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType(MessageConstant.FAIL_TYPE);
            messageBean.setCode(MessageConstant.FAIL);
            messageBean.setMessage("查询线路统计失败");
        }
        return messageBean;
    }

    /**
     * 月度项目申请数量统计
     */
    @RequestMapping("/saverMonth")
    public MessageBean saverMonth(@RequestBody Map<String, String> map) {
        MessageBean messageBean = new MessageBean();
        try {
            Map<String, Object> stringObjectMap = statisticsProjectService.saverMonth(map);
            messageBean.setType(MessageConstant.SUCCESS_TYPE);
            messageBean.setCode(MessageConstant.SUCCESS);
            messageBean.setMessage("查询项目申请数量统计成功");
            messageBean.setData(stringObjectMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType(MessageConstant.FAIL_TYPE);
            messageBean.setCode(MessageConstant.FAIL);
            messageBean.setMessage("查询项目申请数量统计失败");
        }
        return messageBean;
    }

/**
 * 项目申请数(占比统计)
 */

@RequestMapping("/projectApplication")
public MessageBean projectApplication(@RequestBody Map<String, String> map) {
    MessageBean messageBean = new MessageBean();
    try {
        List<Map<String, Object>> stringObjectMap = statisticsProjectService.projectApplication(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询项目申请数情况成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询项目申请失败");
    }
    return messageBean;
}

/**
 * 项目总数、关键指标
 */
@RequestMapping("saverProject")
    public MessageBean saverProject(@RequestBody Map<String, String> map){
    MessageBean messageBean = new MessageBean();
    try {
        Map<String, Object> stringObjectMap = statisticsProjectService.saverProject(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询项目指标成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询项目指标失败");
    }
    return messageBean;
}


/**
 * 项目总体情况——阶段统计
 */
@RequestMapping("/phaseStatistics")
public MessageBean phaseStatistics(@RequestBody Map<String, String> map) {
    MessageBean messageBean = new MessageBean();
    try {
        List<Map<String, Object>> stringObjectMap = statisticsProjectService.phaseStatistics(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询阶段统计成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询阶段统计失败");
    }
    return messageBean;
}

/**
 * 项目运营情况统计
 */
@RequestMapping("/projectOperation")
public MessageBean projectOperation(@RequestBody Map<String, String> map) {
    MessageBean messageBean = new MessageBean();
    try {
        List<Map<String, Object>> stringObjectMap = statisticsProjectService.projectOperation(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询项目运营情况成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询项目运营情况失败");
    }
    return messageBean;
}

/**
 * 我的任务——任务数量
 */

@RequestMapping("/projectTask")
public MessageBean projectTask(@RequestBody Map<String, String> map) {
    MessageBean messageBean = new MessageBean();
    try {
        Map<String, Object> stringObjectMap = statisticsProjectService.projectTask(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询任务数量成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询任务数量失败");
    }
    return messageBean;
}

/**
 * 我的任务——审核工作统计
 */
@RequestMapping("/statisticalWork")
public MessageBean statisticalWork(@RequestBody Map<String, String> map) {
    MessageBean messageBean = new MessageBean();
    try {
        List<Map<String, Object>> stringObjectMap=statisticsProjectService.statisticalWork(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询工作统计成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询工作统计失败");
    }
    return messageBean;
}

/**
 * 我的任务——项目参与情况
 */
@RequestMapping("/projectParticipants")
public MessageBean projectParticipants(@RequestBody Map<String, String> map) {
    MessageBean messageBean = new MessageBean();
    try {
        List<Map<String, Object>> stringObjectMap=statisticsProjectService.projectParticipants(map);
        messageBean.setType(MessageConstant.SUCCESS_TYPE);
        messageBean.setCode(MessageConstant.SUCCESS);
        messageBean.setMessage("查询项目参与情况成功");
        messageBean.setData(stringObjectMap);
    } catch (Exception e) {
        e.printStackTrace();
        messageBean.setType(MessageConstant.FAIL_TYPE);
        messageBean.setCode(MessageConstant.FAIL);
        messageBean.setMessage("查询项目参与情况失败");
    }
    return messageBean;
}

}
